﻿Imports Infragistics.Win.UltraWinGrid
Imports Infragistics.Win
Public Class IUltraDropDown
    Inherits UltraDropDown

    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
        MyBase.OnPaint(e)
        'Add your custom paint code here
    End Sub
    ''' <summary>
    ''' set giao diện (tự động co dãn theo độ dài dữ liệu)
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub setGiaoDien()
        Me.DisplayLayout.Override.RowSelectorNumberStyle = RowSelectorNumberStyle.VisibleIndex
        Me.DisplayLayout.Override.RowAlternateAppearance.BackColor = Color.LightCyan
        Me.DisplayLayout.Override.RowSelectorAppearance.ForeColor = Color.Black
        Me.DisplayLayout.Override.RowSelectorWidth = 30
        Me.DisplayLayout.Override.SelectedRowAppearance.BackColor = Color.Pink
        'mở rộng các cột cho vừa
        'me.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns
        'cho sắp xếp các cột khi click lên header mỗi cột
        Me.DisplayLayout.Override.HeaderClickAction = Infragistics.Win.UltraWinGrid.HeaderClickAction.SortMulti
        'co dãn theo dữ liệu
        Me.DisplayLayout.Bands(0).PerformAutoResizeColumns(False, PerformAutoSizeType.AllRowsInBand, True)
        'me.DisplayLayout.Override.RowSelectorAppearance.BackColor2 = Color.White
        Me.DisplayLayout.Override.RowSpacingAfter = 0
        Me.DisplayLayout.Override.RowSpacingBefore = 0
        Me.DisplayLayout.Override.RowSizingAutoMaxLines = 1
        Me.DisplayLayout.Override.HeaderAppearance.TextHAlign = HAlign.Center
        Me.DisplayLayout.Override.RowAppearance.BorderColor = Color.Gray
        Me.UseFlatMode = DefaultableBoolean.True
        Me.DisplayLayout.Override.HeaderAppearance.FontData.Bold = DefaultableBoolean.True
        Me.DisplayLayout.Override.HeaderAppearance.TextHAlign = HAlign.Center
        'set format ultragrid
        Me.setFormatUltraGrid(Me)
    End Sub
    ''' <summary>
    ''' set giao diện (tự động co dãn theo độ dài dữ liệu) và phần header của cột iultradropdown
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub setGiaoDien_An_ColumnHeader()
        setGiaoDien()
        Me.DisplayLayout.Bands(0).ColHeadersVisible = False
    End Sub
    Private Sub setFormatUltraGrid(ByVal udd As UltraDropDown)
        Dim dataType As String
        For index As Integer = 0 To udd.Rows.Band.Columns.Count - 1
            dataType = udd.Rows.Band.Columns(index).DataType.ToString
            If (dataType = "System.DateTime" Or dataType = "System.Double" Or dataType = "System.Decimal" Or dataType = "System.Int16" Or dataType = "System.Int32" Or dataType = "System.Int64") Then
                udd.Rows.Band.Columns(index).CellAppearance.TextHAlign = HAlign.Right
            End If
        Next
    End Sub
    'Public Sub setTimKiemTrenCotUltraDropDown()
    '    Me.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.True
    '    Me.DisplayLayout.Override.FilterUIType = FilterUIType.FilterRow
    '    Me.DisplayLayout.Override.FilterOperandDropDownItems = FilterOperandDropDownItems.CellValues
    '    Me.DisplayLayout.Override.FilterEvaluationTrigger = FilterEvaluationTrigger.OnCellValueChange
    '    'me.DisplayLayout.Override.FilterOperatorDefaultValue = _
    '    '  FilterOperatorDefaultValue.DoesNotContain
    '    For index As Integer = 0 To Me.Rows.Band.Columns.Count - 1
    '        If (Me.Rows.Band.Columns(index).DataType.FullName.ToString = "System.DateTime") Or (Me.Rows.Band.Columns(index).DataType.FullName.ToString = "System.Double") Or (Me.Rows.Band.Columns(index).DataType.FullName.ToString = "system.Decimal") Or (Me.Rows.Band.Columns(index).DataType.FullName.ToString = "system.Int16") Or (Me.Rows.Band.Columns(index).DataType.FullName.ToString = "system.Int32") Or (Me.Rows.Band.Columns(index).DataType.FullName.ToString = "system.Int64") Then
    '            Try
    '                Me.Rows.Band.Columns(index).FilterOperatorDefaultValue = FilterOperatorDefaultValue.Equals
    '                Me.Rows.Band.Columns(index).FilterOperandStyle = FilterOperandStyle.Combo
    '            Catch ex As Exception
    '                MessageBox.Show("lỗi 'setTimKiemTrenCot' !!!")
    '            End Try
    '        Else
    '            Me.Rows.Band.Columns(index).FilterOperatorDefaultValue = FilterOperatorDefaultValue.Contains
    '        End If
    '    Next
    'End Sub
End Class
